package com.oracle.service;

import com.oracle.mapper.AccountMapper;
import com.oracle.vo.Account;
import com.oracle.vo.AccountExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class UserService {
    @Autowired
    private AccountMapper accountMapper;
    public Account userlogin(String userName, String userPwd) {
        AccountExample accountExample =new AccountExample();
        AccountExample.Criteria criteria = accountExample.createCriteria();
        criteria.andUsernameEqualTo(userName);
        criteria.andPasswordEqualTo(userPwd);
        List<Account> users = accountMapper.selectByExample(accountExample);
        return users.isEmpty()?null:users.get(0);


    }

    public Integer validateUserName(String userName) {
        Account account = accountMapper.selectByUserName(userName);
    return Objects.isNull(account)?0:1;
    }
}
